package org.esuml.ui.swing;

import java.awt.EventQueue;

import javax.swing.JFrame;

import org.esuml.ui.swing.frame.MainFrame;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;

@ComponentScan("org.esuml")
@EnableAutoConfiguration
@SpringBootApplication
public class ApplicationStartup implements CommandLineRunner {

	private static ConfigurableApplicationContext ctx;

	public static void main(String[] args) {
		
		ctx = new SpringApplicationBuilder(ApplicationStartup.class).headless(false).run(args);
	}
	
	@Override
	public void run(String... args) throws Exception {
		 EventQueue.invokeLater(new Runnable() {

			@Override
			public void run() {

				MainFrame frame = ctx.getBean(MainFrame.class);
				frame.setVisible(true);
			}
		 
		 });
		
	}
	
}
